<?php
abstract class Core_Model_DbTable_Base_Action extends Zend_Db_Table_Abstract {
    protected $_id_social_name = NULL;
    
    abstract public function getDetail($id_socials);
    
    public function insertBatchData($array_data) {
        if (empty($array_data)) {
            return;
        }
        $cols = $this->getCols();
        $str_cols = $this->colsToStr($cols);
        $sql = "INSERT IGNORE INTO {$this->_name} ($str_cols) VALUES ";
        foreach ($array_data as $data) {
            $prepared_data = array();
            foreach ($cols as $col) {
                if (!isset($data[$col])) {
                    $prepared_data[] = NULL;
                } else {
                    $prepared_data[] = $data[$col];
                }
            }
            $val  = $this->getAdapter()->quoteInto("(?),", $prepared_data);
            $sql .= $val;
        }
        $final_sql = rtrim($sql, ",");
        $this->getAdapter()->query($final_sql);
    }    
    
    
    protected function getStrCols() {
        $cols = $this->getCols();
        return $this->colstoStr($cols);
    }
    
    protected function colsToStr($cols) {
        $result = "";
        foreach ($cols as $col) {
            $result .= "`$col`,";
        }
        return rtrim($result, ",");        
    }
  
    abstract protected function getCols();
}
?>
